from Autotests.LocalMachine.Pages.BasePage import BaseWebPage, BaseWebManagerPage
from Autotests.LocalMachine.UiObjectsMap.AirClient import Dialog
from Autotests.LocalMachine.Controls import WebButton
from Autotests.LocalMachine.Controls.TreeView import WebTreeView, WebTreeViewDelegateBuilder, WebTreeViewItem
from Autotests.LocalMachine.UiObjectsMap.AirClient import TreeDialog


class BaseWebDialog(BaseWebPage):
    def __init__(self):
        super(BaseWebDialog, self).__init__(Dialog.anyDialog)


class BaseWebManagerDialog(BaseWebManagerPage):
    def __init__(self):
        super(BaseWebManagerDialog, self).__init__(Dialog.anyDialog)


class BaseWebTreeDialog(BaseWebDialog):
    def __init__(self):
        super(BaseWebTreeDialog, self).__init__()
        self._buttonOK = WebButton(TreeDialog.btnOK)
        self._buttonCancel = WebButton(TreeDialog.btnCancel)
        self._treeViewTempDir = WebTreeView(TreeDialog.treeView, WebTreeViewDelegateBuilder(WebTreeViewItem))

    def goToHomeLocation(self):
        pass

    def setItemSelection(self, path):
        self._treeViewTempDir.setItemSelection(path, True)
        self._buttonOK.click()
